<template>
  <div class="basic-member-page">
    <el-card class="member-card">
      <template #header>
        <div class="card-header">
          <span>会员管理</span>
          <el-button type="primary" @click="handleAdd" v-if="hasPerm('basic:member:add')">新增</el-button>
        </div>
      </template>
      
      <el-table :data="dataList" style="width: 100%">
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="name" label="名称" width="150" />
        <el-table-column prop="code" label="编码" width="120" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
              {{ scope.row.status === 'active' ? '启用' : '禁用' }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200">
          <template #default="scope">
            <el-button size="small" @click="handleView(scope.row)" v-if="hasPerm('basic:member:view')">查看</el-button>
            <el-button size="small" type="primary" @click="handleEdit(scope.row)" v-if="hasPerm('basic:member:edit')">编辑</el-button>
            <el-button size="small" type="danger" @click="handleDelete(scope.row)" v-if="hasPerm('basic:member:delete')">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { hasPerm } from '@/utils/permission'
import { ElMessage } from 'element-plus'

const dataList = ref([])

const handleAdd = () => {
  ElMessage.info('新增功能')
}

const handleView = (row) => {
  ElMessage.info(`查看：${row.name}`)
}

const handleEdit = (row) => {
  ElMessage.info(`编辑：${row.name}`)
}

const handleDelete = (row) => {
  ElMessage.info(`删除：${row.name}`)
}

onMounted(() => {
  // 模拟数据
  dataList.value = [
    {
      id: 1,
      name: '示例数据1',
      code: 'CODE001',
      status: 'active'
    },
    {
      id: 2,
      name: '示例数据2',
      code: 'CODE002',
      status: 'active'
    }
  ]
})
</script>

<style scoped>
.basic-member-page {
  padding: 20px;
}

.member-card {
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>